<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/util_file/common.jspf"%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
#admin_product {
	font: 12px/1.2 "돋움", dotum, bold;
}

th {
	background-color: #f1f1f1
}
</style>

<!-- <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> 
<script type="text/javascript" src="/jeons/js/jquery.nyroModal.custom.js"></script>  
<link rel="stylesheet" href="/jeons/css/nyroModal/nyroModal.css" type="text/css" media="screen"/>
<script src="/jeons/js/jquery.metadata.js" type="text/javascript"></script>
<script src="/jeons/js/jquery.validate.js" type="text/javascript"></script> 
<script src="/jeons/js/jquery.metadata.js" type="text/javascript"></script>
<script type="text/javascript" src="/jeons/js/jquery.meio.mask.min.js"></script> -->
<script type="text/javascript" src="/jeons/js/jquery.nyroModal.custom.js"></script>
<link rel="stylesheet" href="/jeons/css/nyroModal/nyroModal.css" type="text/css" media="screen" />
<script src="/jeons/js/jquery.metadata.js" type="text/javascript"></script>
<script src="/jeons/js/jquery.validate.js" type="text/javascript"></script>
<script type="text/javascript" src="/jeons/js/jquery.ui.datepicker.js"></script>
<script type="text/javascript" src="/jeons/js/datepicker.util.js"></script>
<script type="text/javascript" src="/jeons/js/jquery.meio.mask.min.js"></script>
<script type="text/javascript" src="/jeons/js/jquery.popupWindow.js"></script>
<script type="text/javascript">
	$(document).ready(
			function() {

				//콤마없애기
				function removeComma(input) {
					return input.replace(/,/gi, "");
				}

				//팝업
				$(".nm").nm({
					sizes : {
						minW : 400,
						maxW : 500,
						minH : 400,
						maxH : 400
					}
				});
				//팝업 결제 
				$(".tmp").nm({
					sizes : {
						minW : 400,
						maxW : 300,
						minH : 400,
						maxH : 400
					}
				});

				//기본 주소 사용
				$('[name=basicaddress]').click( function() {
							if ($(this).is(":checked")) {
								if ($(this).attr('value') == 'send') {$('[name=send_ars]').val($('#username').val());
									$('[name=send_zipcode]').val($('#userzipcode').val());
									$('[name=send_useraddress]').val($('#useraddress').val());
									$('[name=send_useraddress02]').val($('#useraddress02').val());
									$('[name=send_phone]').val(0 + $('#userphonenumber').val());
								} else {
									$('[name=receive_ars]').val($('#username').val());
									$('[name=receive_zipcode]').val($('#userzipcode').val());
									$('[name=receive_useraddress]').val($('#useraddress').val());
									$('[name=receive_useraddress02]').val($('#useraddress02').val());
									$('[name=receive_phone]').val($(0 + '#userphonenumber').val());
								}
							} else {
								if ($(this).attr('value') == 'send') {$('#send input').val(' ');
								} else {
									$('#receive input').val(' ');
								}
							}

						});

				/*  var tmp_goods = removeComma($('#goods_price').val());
				 $('#goods_price_i').val(parseInt(tmp)); */

				/********************************포인트 부분**************************/
				//포인트 초기값
				var tmep = $('#userid_poin').text();
				//포인트사용
				$('#point_write').blur(
						function() {
							var tmp = $('#userid_poin').text();
							var tmp_goods_pb = removeComma($('#goods_price_pb').val());
							if ($('#point_write').val() > parseInt(tmp)) {
								alert('보유하신 포인트보다 값이 큽니다.');
							} else {$('#userid_poin').text(parseInt(tmp)- $('#point_write').val());
								$('#goods_price_pb').val(parseInt(tmp_goods_pb)- $('#point_write').val());
								$('#goods_price_result').val($('#goods_price_pb').val());

							}

						});

				//사용
				$('#point_write').blur(
						function() {
							if ($('#point_write').val().length == 0
									&& $('#point_write').val().length == " ") {
								$('#userid_poin').text(tmep);
							}
						});

				//유저포인트를 적으면 인풋창값을 없애버린다.
				$('#point_write').click(function() {
					$('#point_write').val('');
					$('#userid_poin').text(tmep);
					$('#goods_price_pb').val($('#goods_price_pa').val());
					$('#goods_price_result').val($('#goods_price_pb').val());
				});

				$('#point_write').setMask('999999');
				//가격 패턴
				/* $('#goods_price_pb').setMask('999,999,999,999');
				$('#goods_price_pa').setMask('999,999,999,999');
				$('#uprice_a').setMask('999,999,999,999'); */
				/* $('#del').setMask('999,999,999,999');  */

				/**************************************************************/

				//팝업창
				$('.example1demo').popupWindow({
					height : 450,
					width : 675,
					top : 50,
					left : 50
				});

				//결제선택시 변수에 결제 방법을 저장해둠
				var pay_sort;

				//결제 페이지 불러오기
				$('#BtnPaySort').click(
					function() {
						$('#goods_name_result').val($("#goods_name").val()); //결제 방식중 하나를 선택하면 상품이름을 저장
						$('#goods_price_result').val(
								$('#goods_price_pb').val()); // 상품 총 결제 금액을 저장 
						if (pay_sort == "BtnMutong") {
							var obj = $("#pay").serialize();
							$.post('/jeons/basket/user_pay_Ok',
									obj, function(data) {
										alert(data);
										$("#subpage_pay").replaceWith(data);

									});
						} else {
							alert('준비중입니다.');
						}

					});

				//결제방법 체크는 하나만
				$('[name=p_way]').click(function() {
					$('#goods_name_result').val($("#goods_name").val());
					pay_sort = $(this).attr('value');
					$(this).siblings().removeAttr("checked");
				});

				$(".nyroModal").nm({
					sizes : {
						minW : 400,
						maxW : 300,
						minH : 400,
						maxH : 400
					}
				});

			});
</script>
<input type="hidden" value="${userdata.username}" id="username" />
<input type="hidden" value="${userdata.useraddress}" id="useraddress" />
<input type="hidden" value="${userdata.useraddress02}" id="useraddress02" />
<input type="hidden" value="${userdata.userzipcode}" id="userzipcode" />
<input type="hidden" value="${userdata.phoncode}" id="phoncode" />
<input type="hidden" value="${userdata.userphonenumber}" id="userphonenumber" />
<input type="hidden" value="${userdata.username}" id="usertelecom" />
<input type="hidden" value="${userdata.point}" id="point" />
<input type="hidden" value="${data.goods_name}" id="goods_name" />
<div id="admin_product" >
	<div id="subpage">
		<div>
			<b>*주문자님의 총 결제 금액</b>
		</div>
		<form id="basket_info">
			<table border="0" width="650px" height="50">
				<input type="hidden" id="goods_price_pa" name="goods_price_pa"
					value="${data.price_i + data.addtion_i+data.delivery}" />
				<tr>
					<td colspan="4" bgcolor="#000000" height="1"></td>
				</tr>
				<tr>
					<th align="center"></th>
					<th align="center"></th>
					<th align="center">상품금액총합계</th>
					<th align="center"><input type="text" name="uprice_a"
						id="uprice_a" value="${data.price_i + data.addtion_i}"
						style="text-align: right;" /></th>
				</tr>
				<td colspan="4" bgcolor="#ffffff" height="1"></td>
				<tr>
					<th align="center"></th>
					<th align="center"></th>
					<th align="center">배송비 총금액</th>
					<th align="center"><input type="text" id="del"
						value="${data.delivery}" style="text-align: right;" /></th>
				</tr>
				<td colspan="4" bgcolor="#ffffff" height="1"></td>
				<tr>
					<th align="center"></th>
					<th align="center"></th>
					<th align="center">총 주문 합계 금액</th>
					<th align="center"><input type="text" id="goods_price_pb"
						name="goods_price_pb"
						value="${data.price_i + data.addtion_i+data.delivery}"
						style="text-align: right;" /></th>
				</tr>
				<td colspan="4" bgcolor="#ffffff" height="1"></td>
				<tr>
					<td>포인트 사용</td>
					<td><input type="text" id="point_write" name="point_write" /></td>
					<td colspan="3">전효님의 사용가능한포인트<label><b
							id="userid_poin">${userdata.point}</b></label></td>
				</tr>
				<td colspan="4" bgcolor="#000000" height="1"></td>
			</table>
		</form>
		<br>
		<div id="info">
			<div>
				<b>*주문자 정보</b> <input type="checkbox" name="basicaddress"
					value="send" />기본 주소 사용
			</div>
			<hr>
			<form id=delivery>
				<%-- <input type="text" name="u_id" value="${sessionScope.u_id}"/> --%>
				<table border="0" width="650px" height="50" id="send">
					<tr>
						<td colspan="2" bgcolor="#000000" height="1"></td>
					</tr>
					<tr>
						<td colspan="2" bgcolor="#ffffff" height="1"></td>
					</tr>
					<tr>
						<th align="center">이름</th>
						<td><input type="text" name="send_ars" id="send_ars" /></td>
					</tr>
					<tr>
						<td colspan="2" bgcolor="#ffffff" height="1"></td>
					</tr>
					<tr>
						<th align="center" rowspan="5">주소</th>
						<td><input type="text" name=send_zipcode /> <a href="/jeons/zipcode/index2?type=send" class="nm"><button type="button">우편번호 검색</button></td>
					</tr>
					<tr>
						<td colspan="1" bgcolor="#ffffff" height="1"></td>
					</tr>
					<tr>
						<td><input type="text" name="send_useraddress" /></td>
					</tr>
					<tr>
						<td colspan="1" bgcolor="#ffffff" height="1"></td>
					</tr>
					<tr>
						<td><input type="text" name="send_useraddress02" /></td>
					</tr>
					<tr>
						<td colspan="2" bgcolor="#ffffff" height="1"></td>
					</tr>
					<tr>
						<td colspan="2" bgcolor="#ffffff" height="1"></td>
					</tr>
					<tr>
						<th align="center">핸드폰번호</th>
						<td><input type="text" name="send_phone" /></td>
					</tr>
					<tr>
						<td colspan="2" bgcolor="#ffffff" height="1"></td>
					</tr>
					<tr>
						<td colspan="2" bgcolor="#ffffff" height="1"></td>
					</tr>
					<tr>
						<th align="center">남기고 싶은말</th>
						<td><input type="text" name="u_comment" /></td>
					</tr>
					<tr>
						<td colspan="2" bgcolor="#000000" height="1"></td>
					</tr>
				</table>
				<br>
				<div>
					<b>*배송자 정보</b><input type="checkbox" name="basicaddress" />기본 주소 사용
				</div>
				<table border="0" width="650px" height="50" id="receive">
					<tr>
						<td colspan="2" bgcolor="#000000" height="1"></td>
					</tr>
					<tr>
						<td colspan="2" bgcolor="#ffffff" height="1"></td>
					</tr>
					<tr>
						<th align="center">이름</th>
						<td><input type="text" name="receive_ars" /></td>
					</tr>
					<tr>
						<td colspan="2" bgcolor="#ffffff" height="1"></td>
					</tr>
					<tr>
						<th align="center" rowspan="5">주소</th>
						<td><input type="text" name="receive_zipcode" /><a href="/jeons/zipcode/index2?type=rereceive" class="nm"><button type="button">우편번호 검색</button></td>
					</tr>
					<tr>
						<td colspan="1" bgcolor="#ffffff" height="1"></td>
					</tr>
					<tr>
						<td><input type="text" name="receive_useraddress" /></a></td>
					</tr>
					<tr>
						<td colspan="1" bgcolor="#ffffff" height="1"></td>
					</tr>
					<tr>
						<td><input type="text" name="receive_useraddress02" /></td>
					</tr>
					<tr>
						<td colspan="2" bgcolor="#ffffff" height="1"></td>
					</tr>
					<tr>
						<td colspan="2" bgcolor="#ffffff" height="1"></td>
					</tr>
					<tr>
						<th align="center">핸드폰번호</th>
						<td><input type="text" name="receive_phone" /></td>
					</tr>
					<tr>
						<td colspan="2" bgcolor="#000000" height="1"></td>
					</tr>
				</table>
			</form>
		</div>
		<br>
		<div>
			<b>*결제</b>
		</div>
		<form id="pay">
			<input type="hidden" name="goods_price_result" id="goods_price_result" /> <input type="hidden" name="goods_name_result" id="goods_name_result" />
		</form>
		<form id="pay_ok">
			<table border="0" width="650px" height="50">
				<tr>
					<td colspan="2" bgcolor="#000000" height="1"></td>
				</tr>
				<tr>
					<td colspan="2" bgcolor="#ffffff" height="1"></td>
				</tr>
				<tr>
					<th align="center">결제방법</th>
					<td><input type="checkbox" id="BtnMu" name="p_way" value="BtnMutong" />무통장 입금 <input type="checkbox" id="BtnMu" name="p_way" value="BtnCard" />카드결제 <input type="checkbox" id="BtnMu" name="p_way" value="BtnTime" />카드결제 <input type="checkbox" id="BtnMu" name="p_way" value="phonepay" />핸드폰결제</td>
				</tr>
				<tr>
					<td colspan="2" bgcolor="#ffffff" height="1"></td>
				</tr>
				<tr>
					<td colspan="2" bgcolor="#000000" height="1"></td>
				</tr>
				<tr>
					<td colspan="2" align="right"><a href="/jeons/basket/user_pay_Ok" class="nm"><button type="button" id="BtnPaySortaa">다음</button></a></td>
<!-- 					<td colspan="2" align="right"><button type="button" id="BtnPaySort">다음</button></td> -->
				</tr>
			</table>
			<br>
			<div id="subpage_pay"></div>
		</form>
	</div>
</div>
<<<<<<< .mine
<br>
<div><b>*결제</b></div> 
<form id="pay">
<input type="text" name="goods_price_result" id="goods_price_result"/>
<input type="text" name="goods_name_result" id="goods_name_result"/>
</form>
<form id="pay_ok">
<table border="0" width="650px" height="50">
	<tr>
		<td colspan="2" bgcolor="#000000" height="1"></td>
	</tr>
	<tr>
		<td colspan="2" bgcolor="#ffffff" height="1"></td>
	</tr>
	<tr>
		<th align="center">결제방법</th>
		<td>
		<input type="checkbox" id="BtnMu" name="p_way" value="BtnMutong"/>무통장 입금
		<input type="checkbox" id="BtnMu" name="p_way" value="BtnCard"/>카드결제
		<input type="checkbox" id="BtnMu" name="p_way" value="BtnTime"/>카드결제
		<input type="checkbox" id="BtnMu" name="p_way" value="phonepay"/>핸드폰결제
	</td>
	</tr>
	<tr>
		<td colspan="2" bgcolor="#ffffff" height="1"></td>
	</tr>
	<tr>
		<td colspan="2" bgcolor="#000000" height="1"></td>
	</tr>
	<tr><Td colspan="2" align="right">
			
				<a href="/jeons/basket/user_pay_Ok" class="nm"><button type="button" id="BtnPaySortaaa">다음</button></a>
			
	</td></tr>
</table>
<br>
<div id="subpage_pay">
</div>	
</form>
		

